<?php
/**
 * Description of View
 *
 * @author pdelavega
 */
class App_View_Helper_View
{
    public function setViewModuleDirectory($module = 'default')
    {
        $session = new Zend_Session_Namespace('Default');
        $layout = Zend_Layout::getMvcInstance();

        $view = $layout->getView();
        
        if (file_exists(PUBLIC_PATH.'/'.$session->theme.'/'.$module))
        {
            $view->addBasePath(PUBLIC_PATH.'/'.$session->theme.'/'.$module);
        }
        else
        {
            $view->addBasePath(PUBLIC_PATH.'/'.$session->theme.'/default');
        }
    }
    
    public function getTHandLink($label,$varName,$sort=false,$tableLink='',$sortField='',$sortDir='')
    {
        
        if ($sort){
            $string = "<th";
            if (strtolower($varName) == strtolower($sortField)){
                $string .= ">"; // add class into TH depending of the sortDir
                $img = '<img style="border: 0px" src="'.$this->theme("/img/admin/$sortDir.png").'" >';
                
                $string .= "<a href='$tableLink/$varName/$sortDir'>$label $img</a>";
            }else{
                $string .= ">"; //TH dont have class
                $img = '<img style="border: 0px" src="'.$this->theme("/img/admin/DESC.png").'" >';
                $string .= "<a href='$tableLink/$varName/DESC'>$label $img</a>";
            }
            $string .= "</th>";
        }else{
            $string = "<th class='nobg'>$label</th>";
        }
        
        return $string;
    }
    
}
?>